package com.demo.bigdata.sql

import org.apache.spark.sql.{SaveMode, SparkSession}

object SqlDemo {
  def main(args: Array[String]): Unit = {
    val spark = SparkSession
      .builder()
      .appName("Spark SQL Demo")
      .master("local")
      .getOrCreate()
    import spark.implicits._

    val path = "nsr_fxdj.csv"
    val data = spark.read.csv(path)
    data.createOrReplaceTempView("fxdj")
    val df = spark.sql("select * from fxdj")
    df.foreach(println(_))
    df.write.mode(SaveMode.Overwrite).text("./data/1")
  }
}
